package Q415


/**
 * 字符串相加
 * @author 23737
 * @date 2022.5.10
 */
fun main(){

}

 class Solution {
    fun addStrings(num1: String, num2: String): String {
        val sb = StringBuilder()
        var carry = 0
        var i = num1.length - 1
        var j = num2.length - 1
        while (i >= 0 || j >= 0 || carry != 0) {
            if (i >= 0) carry += num1[i--] - '0'
            if (j >= 0) carry += num2[j--] - '0'
            sb.append(carry % 10)
            carry /= 10
        }
        return sb.reverse().toString()
    }
}